//Accepted
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <iostream>
#include <list>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

int a[350][350], c[350][350], n, i, j;
bool b[350][350];
int maxx(int x,  int y){
	return x>y?x:y;
}
int rec(int x, int y){
	if(x==n)return 0;
	if(b[x][y])return c[x][y];
	
	b[x][y]=1;
	c[x][y]=a[x][y]+maxx(rec(x+1, y),rec(x+1, y+1));
	
	return c[x][y];
}
int main (){
	//freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);
	scanf("%d", &n);
	memset(b,0, sizeof(b));
	for(i=0;i<n;++i){
		for(j=0;j<=i;++j){
			scanf("%d", &a[i][j]);
		}
	}
	rec(0,0);
	printf("%d",c[0][0]);
	return 0;
}
